const express = require('express');
const fs = require('fs');//引入文件读写模块
const promisify = require('util').promisify;
const readFile = promisify(fs.readFile);

const app = express();

app.get('/index',async (req,res,next)=>{
    try{
        await readFile('./aaa.js')
    }catch(ex){
        next(ex);
    }
})
//错误处理中间件
app.use((err,req,res,next)=>{
    res.status(500).send(err.message)
})


app.listen(3000);
console.log('启动成功');